package com.example.review.tools;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.text.SimpleDateFormat;
import java.util.Date;

public class transformTools {

    public static String Object2Json(Object object){
        String jsonString = "";
        try {
            if(object != null){
                // 创建 ObjectMapper 实例
                ObjectMapper objectMapper = new ObjectMapper();

                // 将对象转换为 JSON 字符串
                jsonString = objectMapper.writeValueAsString(object);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jsonString;
    }

    public static String getCurrentDate(){
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
    }
}
